// ==UserScript==
// @name ktools
// @author 曹开春
// @description 网页小工具
// @version 1.0.1
// @namespace caokaichun_ktools
// @run-at document-end
// @updateURL https://gitee.com/caokaichun/ktools/raw/master/topbottom.js
// @downloadURL https://gitee.com/caokaichun/ktools/raw/master/topbottom.js
// @grant GM.setValue
// @grant GM.getValue
// @grant GM.listValues
// @grant GM_addStyle
// @grant unsafeWindow
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js
// @match *://*/*
// @noframes
// ==/UserScript==

//工具定位 left,right,top,bottom;
//gotop,gobottom,常用网址

const keith={"author":"曹开春"};
keith.main='<div id="k82tools"><ul id="k82menu"><li><a href="javascript:void(0)" target="_self" id="k82gotop">顶</a></li><li><a href="javascript:void(0)" target="_self" id="k82gocenter">中</a></li><li><a href="javascript:void(0)" target="_self" id="k82gobtm">底</a></li></ul></div>';

GM_addStyle('#k82tools{position: fixed;left:20px;bottom:20px;font-size:14px;z-index:9999;padding:0;}#k82menu{margin:0;padding:0}#k82menu li{width:26px;height:26px;line-height:26px;border:1px solid #aaa;border-radius:50%;overflow:hidden;margin-bottom:10px;padding:0;}#k82menu li a{display:block;background:#fff;width:100%;height:100%;text-align:center;font-size:14px;padding:0;color:#000;user-select:none;}#k82menu li a:hover{text-decoration: none;color:#000;background:#aaa;}');



(async () => {
  let count_before = await GM.getValue('count', 0);

  // Note awaiting the set -- required so the next get sees this set.
  await GM.setValue('count', count_before + 1);

  // Get the value again, just to demonstrate order-of-operations.
  let count_after = await GM.getValue('count');

  //let get_count=await GM.listValues();

  console.log('Greasemonkey set-and-get Example has run', count_after, 'times');
  //console.log('Greasemonkey listValues',get_count);
  console.log('author:',keith.author);

$("body").prepend(keith.main);

$("body").on('click','#k82gotop', function() {
	$("html,body").animate({
		scrollTop: 0
	}, 100);
});
$("body").on('click','#k82gocenter', function() {
	let bh=$("body").height()/2;
    $("html,body").animate({
		scrollTop: bh
	}, 100);
});

$("body").on('click','#k82gobtm', function() {
	let bh=$("body").height();
	$("html,body").animate({
		scrollTop: bh
	}, 100);
});


})();